Skip to content

Update version checks during DFU update#253

Open
xorptr wants to merge 1 commit into
google:mainfrom
xorptr:dfu_update_version_check
Open

Update version checks during DFU update#253
xorptr wants to merge 1 commit into
google:mainfrom
xorptr:dfu_update_version_check

Conversation

@xorptr
Copy link
Copy Markdown
Collaborator

@xorptr xorptr commented May 19, 2026

  • Do not fail desired ROM_EXT version checks if the running ROM_EXT will cause ROM_EXT boot slot to not change after update
  • Check that the application security version is allowed by current minimum BL0 security version, and fail early if it isn't
  • Do not fail DFU check if the running ROM_EXT version is not the same as the one in the image being checked in cases where this is expected

@xorptr xorptr requested review from korran and stevenportley May 19, 2026 07:47
// version first, and then greater major version, and then greater minor
// version
// ([ref](https://github.com/lowRISC/opentitan/blob/acb2179c7f4b59d4ee2118fb24cfb4f97d920dc9/sw/device/silicon_creator/rom/boot_policy.c#L18-L41))
if (current_rom_ext_version->security_version >
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be easier to understand with a int opentitan_version_cmp(const opentitan_image_version* a, const opentitan_image_version* b) function, which can be easily unit tested.

Copy link
Copy Markdown
Collaborator

@korran korran May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that would be libhoth_ot_version_cmp(), which libhoth_ot_version_eq() can delegate to...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interestingly, libhoth_ot_version_eq() doesn't currently look at security version...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the security version check here matters for the application firmware. The boot policy check for application firmware seems to only consult primary_bl0_slot (called here). And then rom_ext_verify call just checks against min_security_version_bl0 here (called from here).

Same concerns apply for application major and minor firmware. My understanding is that which application firmware version to boot depends primarily on primary_bl0_slot, so using this logic in checking application firmware version would be incorrect.

That's why I limited the logic to ROM_EXT only (expect_active_rom_ext_change_with_update). Even with ROM_EXT, this only helps with comparison against the active ROM_EXT (currently running). The staging ROM_EXT can have a different major and minor version. For eg:

  • Before update: Active ROM_EXT is 0.111 with security version 2. Staging ROM_EXT is 0.111 with security version 2
  • Update to image with ROM_EXT 0.110 with security version 0
  • After update: Active ROM_EXT is 0.111 with security version 2. Staging ROM_EXT is 0.110 with security version 0

I am not sure if putting this logic in a generic opentitan_version_cmp function would be helpful.

bool result = libhoth_ot_version_eq(libhoth_ot_boot_app(resp), desired_app);
if (expect_desired_rom_ext) {
result &=
libhoth_ot_version_eq(libhoth_ot_boot_romext(resp), desired_romext);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we want to complete omit check the ROM_EXT version in this case? Would it make more sense to instead check that the ROM_EXT version hasn't changed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could it change? the version that booted previously is pinned in flash and the ROM will refuse to boot the old one we just flashed...

Copy link
Copy Markdown
Collaborator Author

@xorptr xorptr May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to instead check that the ROM_EXT version hasn't changed

This function is used both at end of DFU update procedure, and during post-update procedure to check whether the running firmware matches what is expected (from the file). I can check that ROM_EXT version hasn't changes at end of the update procedure, but not for the other scenario (since I cannot query the version before the update in that case)

- Do not fail desired ROM_EXT version checks if the running ROM_EXT will cause ROM_EXT boot slot to not change after update
- Check that the application security version is allowed by current minimum BL0 security version, and fail early if it isn't
- Do not fail DFU check if the running ROM_EXT version is not the same as the one in the image being checked in cases where this is expected
@xorptr xorptr force-pushed the dfu_update_version_check branch from 7a9b65f to c66504e Compare May 19, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants